﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Com.Maiyoule.GsmSms.Components {
    class ServiceCenterTimeStamp {
        private DateTime targetTime;
        /// <summary>
        /// 绝对时间
        /// </summary>
        public DateTime TargetTime {
            get { return targetTime; }
            set { targetTime = value; }
        }

        public void SetSCTS(string data) {
            data = Util.ParityChange(data);

            string year = data.Substring(0, 2);
            string month = data.Substring(2, 2);
            string day = data.Substring(4, 2);
            string hour = data.Substring(6, 2);
            string second = data.Substring(8, 2);
            string minit = data.Substring(10, 2);
            string zone = data.Substring(12, 2);
            this.targetTime = DateTime.Parse(string.Format("{0}-{1}-{2} {3}:{4}:{5}", year, month, day, hour, second, minit));
        }

        public string GetSCTS() {
            string d = this.targetTime.ToString("yyMMddHHmmss");
            string zone = this.targetTime.ToString("zz");
            zone = Util.Otc2HexString(Int32.Parse(zone));
            return Util.ParityChange(d) + zone;
        }
    }
}
